<link rel="stylesheet" href="<%= sails.config.cdn_host %>/styles/change_password/index.css?20151229154423">
<p>
    <%= JSON.stringify(account)%>
</p>
<%- partial('../partials/top') %>
<%- partial('../partials/normal_header') %>
<div class="content mt40">
  <%- partial('../partials/user_center') %>
  <div class="right_content">
    <div class="change_password_title">绑定重宝奇兵账号</div>
    <div class="change_password_content">
      <div class="text_name_area">
      </div>
      <form class="text_field_area">
      <p class="userName" style="opacity: 0"></p>
        <div class="input_wrap">
          <input type="text" name="old_password" id="current_password" maxlength="11" placeholder="输入绑定手机" class="phone" />
        </div>
        
        <div class="input_wrap">
        <p>
           <input type="text" name="confirm_password" id="confirm_new_password" maxlength="6" placeholder="输入验证码"  class="code" style="width: 130px;
      height: 20px;border: none;padding-left: 0;border-right: solid 1px #CCCCCC;" />
           <button class="code_box" type="button">获取验证码</button>
        </p>
         
        </div>
        <p class="Voice">收不到验证码，试试 <button class="voiceCode" type="button">语音验证码</button>  </p>
        <p class="change_password_confirm_button" style="width: 249px;">提交绑定</p>
      </form>
    </div>
  </div>
</div>
<%- partial('../partials/footer.ejs') %>
<script src="<%= sails.config.cdn_host %>/js/dependencies/jquery-plugin/jquery.validate.min.js?20151229154423"></script>
<style type="text/css">

  .input_wrap p{
    width: 236px;
    height: 30px;
    border: 1px solid #cccccc;
    padding-left: 10px;
    margin-right: 10px;
    position: relative;
  }
  .voiceCode{
    background: #fff;
    border: none;
    color: #BB1E7B;
    text-decoration:underline;
    cursor: pointer;
    outline: none;
  }
  .Voice{
    font-size: 13px;
  }
  .code_box{
   line-height: 30px;
   cursor: pointer;
   text-align: center;
   color: #BB1E7B;
   border: none;
   background: #fff;
   height: 20px;
   outline: none;
  }
  
  .code{
    display: inline-block;
        width: 48px;
        height: 24px;
  }
  .change_password_confirm_button{
    line-height: 38px;
    text-align: center;
  }
</style>
<script type="text/javascript">
(function(){
     app.userName('',function(response){
        var userName="";
          if(response.user.account.phone){
            userName=response.user.account.phone
          }else if(response.user.account.email){
            userName=response.user.account.email
          }
         $(".userName").text(userName)
        
     })
     function time (){
      var num=60;
      var times=setInterval(function(){
        num--;
        $(".code_box").text("重新获取"+'('+num+')')
      if(num<0){
        clearInterval(times);
        $(".code_box").attr("disabled",false).css("color","#BB1E7B");
        $(".voiceCode").attr("disabled",false).css("color","#BB1E7B");
        $(".code_box").text("重新获取");
        return false
       }
      },1000)

    }
    //获取短信验证码
    $(".code_box").on("click",function(){
      var params = {
            mobile:$(".phone").val(),
            isCheck:0
           
          }; 
       app.binding(params,function(response){
          if(response.execMsg == "成功"){
              time();
             $(".code_box").css("color","#AAAAAA").attr("disabled",true)   
          }
        })
      
    })
    //获取语音验证码
    $(".voiceCode").on("click",function(){
       var params = {
            mobile:$(".phone").val(),
            isCheck:0
          }; 
       app.Voice(params,function(response){
          time();
          $(".code_box").css("color","#AAAAAA").attr("disabled",true)  
          $(".voiceCode").css("color","#AAAAAA").attr("disabled",true)
          
        })

    })
    //获取优众账号

    //提交绑定
    $(".change_password_confirm_button").on("click",function(){
            
            var params = {
                  account:Number($(".userName").text()),
                  mobile:$(".phone").val(),
                  code:$("#confirm_new_password").val()
                }; 
             app.bindAccount(params,function(response){
                alert(response.execMsg)
              })
          })
       
  })()
</script>